package com.nbb.common.constant;


import java.util.ArrayList;
import java.util.List;

/**
 * 常量类定义
 * 
 * @author WangXin
 * 
 */
public class IConstants {

	public static final String LOGIN_PRIVATE_KEY = "0XK2d6jfW3zz1o1k3I@hefantv.com";
	public static final String PWD_PRIVATE_KEY = "g7ZOWGgg6J@heFanTV";


	public static final String PARAM_DATA = "data";


	// 成功码定义
	public static final int HTTP_SUCCESS = 200;

	public static final String CMS_USER_FIELDS = "id,nickName,account,passWord,nickName,type,phone,email,delFlag,positionId,anchorOperationFlag,loginFlag";

	/**
	 * 参数定义
	 * 
	 * @author WangXin
	 * 
	 */
	public static class ParamDefine {

		/**
		 * 查询字段定义
		 * 
		 * @author WangXin
		 * 
		 */
		public static interface QueryFields {

			public static final String FIELDS = "fields";
			public static final String START = "start";
			public static final String SIZE = "size";
			public static final String ORDERCOLUMN = "orderColumn";
			public static final String ORDERDRECTION = "orderDirection";
			public static final String QUERYCONDITIONS = "queryConditions";
			public static final String COLUMNNAME = "columnName";
			public static final String COLUMNVALUE = "columnValue";
			public static final String TYPE = "type";
		}

		/**
		 * 增删改字段定义
		 * 
		 * @author WangXin
		 * 
		 */
		public static interface CudFields {
			public static final String SOURCE = "source";
			public static final String BACK_ID = "back_id";
			public static final String OBJS = "objs";

		}

		/**
		 * 增删改查
		 * 
		 * @author WangXin
		 * 
		 */
		public static enum CrudEnum {
			QUERY, ADD, MODIFY, DELETE;
		}

		/**
		 * 排序定义
		 * 
		 * @author WangXin
		 * 
		 */
		public enum OrderDirection {
			DESC(1), ASC(2),CONVERT_DESC(3), CONVERT_ASC(4);
			private Integer value;

			private OrderDirection(Integer value) {
				this.value = value;
			}

			public static List<Integer> ValueList() {
				List<Integer> list = new ArrayList<Integer>();
				for (OrderDirection c : OrderDirection.values()) {
					list.add(c.value);
				}
				return list;
			}

			/**
			 * @return the value
			 */
			public Integer getValue() {
				return value;
			}

			/**
			 * @param value
			 *            the value to set
			 */
			public void setValue(Integer value) {
				this.value = value;
			}

		}

		/**
		 * 操作符合类型定义
		 * 
		 * @author WangXin
		 * 
		 */
		public static enum OperatorType {

			eq(0, "="), lt(1, "<"), gt(2, ">"), ltgt(3, "<>"), lteq(4, "<="), gteq(
					5, ">="), like(6, "like"),in(7, "in"),notin(8, "notin"),llike(9, "like"),NULL(10, "NULL"),NOTNULL(11, "NotNULL"),dfeq(12,"=");

			private int index;
			private String value;

			private OperatorType(int index, String value) {
				this.index = index;
				this.value = value;
			}

			public static String getValue(int index) {
				for (OperatorType c : OperatorType.values()) {
					if (c.getIndex() == index) {
						return c.value;
					}
				}
				return null;
			}

			public static List<Integer> keyList() {
				List<Integer> list = new ArrayList<Integer>();
				for (OperatorType c : OperatorType.values()) {
					list.add(c.index);
				}
				return list;
			}

			/**
			 * @return the index
			 */
			public int getIndex() {
				return index;
			}

			/**
			 * @param index
			 *            the index to set
			 */
			public void setIndex(int index) {
				this.index = index;
			}

			/**
			 * @return the value
			 */
			public String getValue() {
				return value;
			}

			/**
			 * @param value
			 *            the value to set
			 */
			public void setValue(String value) {
				this.value = value;
			}

		}

		/**
		 * backId定义
		 * 
		 * @author WangXin
		 * 
		 */
		public static enum BackId {
			YES(1), NO(2);
			private Integer value;

			private BackId(Integer value) {
				this.value = value;
			}

			public static  List<Integer> valueList() {
				List<Integer> list = new ArrayList<Integer>();
				for (BackId bi : BackId.values()) {
					list.add(bi.getValue());
				}
				return list;
			}

			/**
			 * @return the value
			 */
			public Integer getValue() {
				return value;
			}

			/**
			 * @param value
			 *            the value to set
			 */
			public void setValue(Integer value) {
				this.value = value;
			}
		}

	}

	/**
	 * 响应信息定义
	 * 
	 * @author WangXin
	 * 
	 */
	public static class ResponseDefine {

		/**
		 * 相应给客户端的编码定义
		 * 
		 * @author WangXin
		 * 
		 */
		public static enum Code {
			SUCCESS_200(200, "操作成功."),
			ERROR_401(401, "您没有权限,没在白名单范围之内."),
			ERROR_402(402, "参数错误."),
			ERROR_403(403,"业务异常"),

			ERROR_500(500, "程序出现异常，异常信息为:"),
			ERROR_501(501,"程序异常"),
			ERROR_505(505, "SQL异常:"),
			ERROR_506(506, "SQL重复KEY异常:")


			;

			private int index;
			private String value;

			private Code(int index, String value) {
				this.index = index;
				this.value = value;
			}

			/**
			 * @return the index
			 */
			public int getIndex() {
				return index;
			}

			/**
			 * @param index
			 *            the index to set
			 */
			public void setIndex(int index) {
				this.index = index;
			}

			/**
			 * @return the value
			 */
			public String getValue() {
				return value;
			}

			/**
			 * @param value
			 *            the value to set
			 */
			public void setValue(String value) {
				this.value = value;
			}

		}

	}

	public static final String PROPERTIES_GET = "get";
	public static final String PROPERTIES_SET ="set";


	public static final String COOKIE_R="_r";
	public static final String COOKIE_U="_u";


}
